<header class="common-header">
    <div class="container">
        <a class="logo" href="{{ url_for('main.index') }}" title="{{ Setting.get_setting('blogtitle') }}"><img src="{{ Setting.get_setting('logo') or url_for('static', filename='dist/images/logo.png') }}" alt="{{ Setting.get_setting('blogtitle') }}"></a>
        <nav>
            <ul class="nav-list">
                {% if Setting.get_setting('navigation') and (json.loads(Setting.get_setting('navigation'))).get('navigations') %}
                {% for nav_setting in (json.loads(Setting.get_setting('navigation'))).get('navigations') %}
                    <li name="{{ nav_setting['primary'].keys()[0] }}" class="">
                        <a href="{{ nav_setting['primary'].values()[0] or 'javascript:void(0)' }}">
                            {{- nav_setting['primary'].keys()[0] -}}
                            {% if nav_setting.get('sub') %}
                            <!--i class="fa fa-angle-down"></i-->
                            <span class="glyphicon glyphicon-menu-down"></span>
                            {% endif %}
                        </a>
                        {% if nav_setting.get('sub') %}
                            <div class="pop-up">
                                <div class="menu">
                                    {% for sub_item in nav_setting.get('sub') %}
                                    <a href="{{ sub_item.values()[0] }}" class="mobile-hide">{{- sub_item.keys()[0] -}}</a>
                                    {% endfor %}
                                </div>
                            </div>
                        {% endif %}
                    </li>
                {% endfor %}
                {% endif %}
            </ul>
        </nav>
        <div class="right-col right-nav-wrapper">
            <ul class="sub-nav">
                <li class="search-item">
                    <a href="javascript:void(0)"><span class="glyphicon glyphicon-search"></span>搜索 </a>
                    <div class="search-wrap pop-up">
                        <div class="searchbar">
                            <form action="/search" class="search-form" method="get">
                                <input type="text" placeholder="搜索" name="s">
                                <button class="search-icon search-btn" type="submit"><i class="glyphicon glyphicon-search"></i> </button>
                            </form>
                        </div>
                    </div>
                </li>
                {% if current_user.is_logged_in %}
                <li class="dropdown user-profile">
                    <a href="javascript:void(0)" class="" data-toggle="dropdown">
                        <img class="avatar" src="{{ current_user.get_avatar(30) }}">
                        <span class="name">{{- current_user.nickname or current_user.name -}}</span>
                        <span class="glyphicon glyphicon-menu-down"></span>
                    </a>
                    <ul class="dropdown-menu user-profile-menu list-unstyled">
                        <li>
                            <a href="{{ url_for('dashboard.new_post') }}"><span class="glyphicon glyphicon-edit"></span>发布文章</a>
                        </li>
                        <li>
                            <a href="{{ url_for('dashboard.my_profile') }}"><span class="glyphicon glyphicon-user"></span>个人资料</a>
                        </li>
                        <li class="last">
                            <a href="{{ url_for('auth.logout') }}"><span class="glyphicon glyphicon-log-out"></span>登出</a>
                        </li>
                    </ul>
                </li>
                {% else %}
                <li class="login-actions">
                    <a href="{{ url_for('auth.login') }}" class="login-link bind-redirect"><span class="glyphicon glyphicon-user"></span>登录/注册</a>
                </li>
                {% endif %}
            </ul>
        </div>

    </div>
</header>